<template>
  <page-meta :page-style="$theme.pageStyle">
    <!-- #ifndef H5 -->
    <navigation-bar :front-color="$theme.navColor" :background-color="$theme.navBgColor" />
    <!-- #endif -->
  </page-meta>
  <z-paging ref="paging" v-model="dataList" @query="queryList" :fixed="true">
    <view class="box-content">
      <view class="pageA">
        <dynamic-list :isShowDeleteItem="true" @deleteItemChange="deleteItemChange" :userData="theUserInfo"
          :dynamicData="dataList"></dynamic-list>
      </view>
    </view>
  </z-paging>

</template>
<script lang="ts" setup>
import { ref, shallowRef } from "vue"
import { getChatGroupListApi, getMyDynamicListApi, getUserInfoApi } from "@/api/new";
import { onLoad, onShow } from "@dcloudio/uni-app";

const toDetail = (item: any) => {
  uni.navigateTo({
    url: '/packagesA/pages/massageDetail/massageDetail?group_id=' + item.id + '&goal_user_id=' + item.data_id
  })
}

const chatFormData = ref(
  {
    page_no: 1,
    page_size: 10,
  }
)

const deleteItemChange = (e: any) => {
  if (e) {
    paging.value.reload()
  }
}

const paging = shallowRef<any>(null)
const dataList = ref()

const queryList = async (page_no: any, page_size: any) => {
  try {
    const { lists } = await getMyDynamicListApi({
      page_no,
      page_size
    })
    paging.value.complete(lists)
  } catch (e) {
    console.log('报错=>', e)
    //TODO handle the exception
    paging.value.complete(false)
  }
}


let theUserInfo = ref()

const getTheUserInfo = async () => {
  theUserInfo.value = await getUserInfoApi({})
}

onLoad(() => {
  getTheUserInfo()
})
</script>
<style scoped lang="scss">
.pageA {
  padding: 0.9375rem;
  border-radius: 0.625rem;
  background-color: #ffffff;
}
</style>